package base.thread_JUC2.chapter03.demo04;

/**
 * CyclicBarrier 的线程任务类
 */
public class GrouperRunnable implements Runnable{
    private Results results;

    public GrouperRunnable(Results results){
        this.results = results;
    }

    @Override
    public void run() {
        int result = 0;
        System.out.printf("CyclicBarrier的任务开始执行：开始处理最终结果...\n");
        for (int num : results.getData()) {
            // 将每行统计到的出现次数进行累加
            result += num;
        }
        System.out.printf("CyclicBarrier的任务: 统计最终结果: %d.\n",result);
    }
}
